﻿@using Abp.Application.Editions
@using Abp.Application.Services.Dto
@using Abp.Extensions
@using Magicodes.Admin.Web.Areas.Admin.Models.Common.Modals
@using Magicodes.Admin.Web.Areas.Admin.Models.Editions
@model CreateOrEditEditionModalViewModel

@Html.Partial("~/Areas/Admin/Views/Common/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(Model.IsEditMode ? (L("EditEdition") + ": " + Model.Edition.DisplayName) : L("CreateNewEdition")))

<div class="modal-body">
    <div class="tabbable-line">
        <ul class="nav nav-tabs ">
            <li class="active">
                <a href="#EditionInformationsTab" data-toggle="tab" aria-expanded="true">
                    @L("EditionProperties")
                </a>
            </li>
            <li class="">
                <a href="#FeaturesTab" data-toggle="tab" aria-expanded="false">
                    @L("Features")
                </a>
            </li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="EditionInformationsTab">

                <form name="EditionInformationsForm" role="form" novalidate class="form-validation">

                    @if (Model.IsEditMode)
                    {
                        <input type="hidden" name="Id" value="@Model.Edition.Id" />
                    }

                    <div class="form-group form-md-line-input form-md-floating-label">
                        <input class="form-control@(Model.Edition.DisplayName.IsNullOrEmpty() ? "" : " edited")"
                               type="text" name="DisplayName"
                               value="@Model.Edition.DisplayName"
                               required
                               maxlength="@Edition.MaxDisplayNameLength">
                        <label>@L("EditionName")</label>
                    </div>

                    <label>@L("SubscriptionPrice")</label>
                    <div class="md-radio-inline">
                        <div class="md-radio">
                            <input id="EditEdition_IsFree" name="SubscriptionPrice" class="md-radiobtn" @(!Model.Edition.MonthlyPrice.HasValue && !Model.Edition.AnnualPrice.HasValue ? "checked=\"checked\"" : "") type="radio">
                            <label for="EditEdition_IsFree">
                                <span class="inc"></span>
                                <span class="check"></span>
                                <span class="box"></span>
                                @L("Free")
                            </label>
                        </div>
                        <div class="md-radio">
                            <input id="EditEdition_IsPaid" name="SubscriptionPrice" class="md-radiobtn" @(Model.Edition.MonthlyPrice.HasValue || Model.Edition.AnnualPrice.HasValue ? "checked=\"checked\"" : "") type="radio">
                            <label for="EditEdition_IsPaid">
                                <span class="inc"></span>
                                <span class="check"></span>
                                <span class="box"></span>
                                @L("Paid")
                            </label>
                        </div>
                    </div>

                    <div class="paid-features">
                        <div class="row SubscriptionPrice">
                            <div class="col-md-6">
                                <div class="form-group form-md-line-input form-md-floating-label">
                                    <input name="MonthlyPrice" 
                                           type="text"
                                           class="form-control@(!Model.Edition.MonthlyPrice.HasValue ? "" : " edited")"
                                           value="@(Model.Edition.MonthlyPrice?.ToString("0.00",System.Globalization.CultureInfo.InvariantCulture))"/>
                                    
                                    <label>@L("MonthlyPrice")</label>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group form-md-line-input form-md-floating-label">
                                    <input name="AnnualPrice" 
                                           type="text"
                                           class="form-control@(!Model.Edition.AnnualPrice.HasValue ? "" : " edited")"
                                           value="@Model.Edition.AnnualPrice?.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)"/>
                                    
                                    <label>@L("AnnualPrice")</label>
                                </div>
                            </div>
                        </div>

                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="EditEdition_IsTrialActive" class="md-check" type="checkbox" name="IsTrialActive" value="true" @(Model.Edition.TrialDayCount.HasValue ? "checked=\"checked\"" : "") />
                                <label for="EditEdition_IsTrialActive">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("IsTrialActive")
                                </label>
                            </div>
                        </div>

                        <div class="form-group form-md-line-input form-md-floating-label trial-day-count">
                            <input class="form-control@(!Model.Edition.TrialDayCount.HasValue ? "" : " edited")"
                                   type="number" name="TrialDayCount"
                                   value="@Model.Edition.TrialDayCount">
                            <label>@L("TrialDayCount")</label>
                        </div>

                        <div class="md-checkbox-list">
                            <div class="md-checkbox">
                                <input id="EditEdition_IsWaitingDayActive" class="md-check" type="checkbox" name="IsWaitingDayActive" value="true" @(Model.Edition.WaitingDayAfterExpire.HasValue ? "checked=\"checked\"" : "") />
                                <label for="EditEdition_IsWaitingDayActive">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("WaitAfterSubscriptionExpireDate")
                                </label>
                            </div>
                        </div>

                        <div class="form-group form-md-line-input form-md-floating-label waiting-day-after-expire">
                            <input class="form-control@(!Model.Edition.WaitingDayAfterExpire.HasValue ? "" : " edited")"
                                   type="number" name="WaitingDayAfterExpire"
                                   value="@Model.Edition.WaitingDayAfterExpire">
                            <label>@L("WaitingDayAfterExpire")</label>
                        </div>

                        <label>@L("WhatWillDoneAfterSubscriptionExpiry")</label>
                        <div class="md-radio-inline">
                            <div class="md-radio">
                                <input id="EditEdition_ExpireAction_DeactiveUser" name="ExpireAction" class="md-radiobtn" @(!Model.Edition.ExpiringEditionId.HasValue ? "checked=\"checked\"" : "") type="radio">
                                <label for="EditEdition_ExpireAction_DeactiveUser">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("DeactiveTenant")
                                </label>
                            </div>
                            <div class="md-radio">
                                <input id="EditEdition_ExpireAction_AssignEdition" name="ExpireAction" class="md-radiobtn" @(Model.Edition.ExpiringEditionId.HasValue ? "checked=\"checked\"" : "") type="radio">
                                <label for="EditEdition_ExpireAction_AssignEdition">
                                    <span class="inc"></span>
                                    <span class="check"></span>
                                    <span class="box"></span>
                                    @L("AssignToAnotherEdition")
                                </label>
                            </div>
                        </div>

                        <div class="form-group form-md-line-input form-md-floating-label edition-list">
                            @Html.DropDownList("ExpiringEditionId", Model.FreeEditionItems.Select(i => i.ToSelectListItem()), new { @class = "form-control" + (Model.Edition.DisplayName.IsNullOrEmpty() ? "" : " edited") })
                        </div>
                    </div>
                </form>

            </div>
            <div class="tab-pane" id="FeaturesTab">
                @Html.Partial("~/Areas/Admin/Views/Common/_FeaturesTree.cshtml", Model)
            </div>
        </div>
    </div>
</div>

@Html.Partial("~/Areas/Admin/Views/Common/Modals/_ModalFooterWithSaveAndCancel.cshtml")